(function () {
  // 获取原密码框内容
  let old_password = document.querySelector('.old_password');
  // 获取新密码框内容
  let new_password = document.querySelector('.new_password');
  // 获取新密码框内容
  let re_password = document.querySelector('.re_password');
  // 获取修改密码
  let btnRevise = document.querySelector('.btn-Revise');
  //获取重置按钮 
  let btnReset = document.querySelector('.btn-reset');
  // 获取提示
  let tips1 = document.querySelector('.tips1');
  let tips2 = document.querySelector('.tips2');
  let tips3 = document.querySelector('.tips3');
  let reset = document.querySelector('.btn-Reset');
  let modal = document.querySelector('.modal');

  // 发送请求
  let judge=/^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/
  // 原密码失焦判断
  new_password.addEventListener('blur', function() {
    if(!judge.test(this.value)){
      tips2.style.opacity = "1"
    }else{
      console.log(111);
      tips2.style.opacity = "0"
    }
  })

  re_password.addEventListener('blur',function(){
    if(this.value !== new_password.value){
      tips3.style.opacity = "1"
    }else{
      tips3.style.opacity = "0"
    }
  } )

  reset.addEventListener('click', function(){
    old_password.value = ''
    new_password.value = ''
    re_password.value = ''
  })

  btnRevise.addEventListener('click', async function(){
    let obj = {
      "old_pwd": old_password.value,
      "new_pwd": new_password.value,
      "re_pwd": re_password.value
    }
    let res = await getUserPwd(obj)
    console.log(res);
    modal.innerHTML = res.data.message
    modal.style.display = 'block'
    setTimeout(() => {
      modal.style.display = 'none'
    }, 2000);
  })
})()